﻿using SCG.Prism;
using SCG.WinForms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SCG.SolarVengeance
{
    public partial class AccountDetailsForm : BaseForm
    {
        //constructor
        public AccountDetailsForm()
        {
            InitializeComponent();
        }

        //access the PrismUser
        public PrismUser PrismUser
        {
            get
            {
                PrismUser user = new PrismUser();
                user.UserName = txtUserName.Text;
                user.Password = txtPassword.Text;
                user.Glyph = picGlyph.Image;
                return user;
            }
            set
            {
                txtUserName.Text = value.UserName;
                txtPassword.Text = value.Password;
                txtPasswordConfirm.Text = value.Password;
                picGlyph.Image = value.Glyph;
            }
        }

        //change image
        private void picGlyph_Click(object sender, EventArgs e)
        {
            if (dlgSelectImage.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    Image img = Image.FromFile(dlgSelectImage.FileName);
                    img = ImageUtils.ResizeBitmap(img, 60, 60, true);
                    picGlyph.Image = img;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("There was a problem loading this image: " + dlgSelectImage.FileName + Environment.NewLine + ex.Message);
                }
            }
        }

        //preset values
        private void AccountDetailsForm_Load(object sender, EventArgs e)
        {
            if (txtUserName.Text == "")
            {
                txtUserName.Text = MainForm.Instance.StarLordName;
                picGlyph.Image = MainForm.Instance.Glyph;
            }
        }
    }
}
